﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Admin.WorkFlow.FormTable.TechnologyContact
{
    public partial class TechnologyContract_ReadOnly : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.Params["id"] != null && Request.Params["id"].ToString() != "")
            {
                BindInfo(ChinaSoft.Common.Input.SetInt(Request.Params["id"]));
            }
        }
        private void BindInfo(int id)
        {
            ChinaSoft.Model.Model_tb_MidSoft_TechnologyContract modelTechContract = new ChinaSoft.Model.Model_tb_MidSoft_TechnologyContract();
            ChinaSoft.BLL.BLL_tb_MidSoft_TechnologyContract bllTechContract = new ChinaSoft.BLL.BLL_tb_MidSoft_TechnologyContract();
            modelTechContract = bllTechContract.GetModel(id);
            if (modelTechContract != null)
            {
                lblConfigDate.Text = Convert.ToDateTime(modelTechContract.ConfirmDate).ToShortDateString();
                lblProfessional.Text = modelTechContract.Professional;
                lblMain.Text = modelTechContract.MainSendUnit;
                lblNumber.Text = modelTechContract.TechnologyContractNumber;
                lblSecertSend.Text = modelTechContract.SecretSendUnit;
                lblAttach.Text = modelTechContract.Attach;
                LiterContent.Text = modelTechContract.ContractContent;
                BindTaskBookInfo(modelTechContract.TaskBookId);
            }
        }
        private void BindTaskBookInfo(int taskBookId)
        {
            ChinaSoft.BLL.Common.Bind bllBind = new ChinaSoft.BLL.Common.Bind();
            DataSet ds = bllBind.GetDataSet("*", "V_TaskBookLook", "TaskBookId=" + taskBookId);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];
                lblCreateUserName.Text = GetProjectUserName(ChinaSoft.Common.Input.SetInt(dr["JingBanId"]));
                lblProjectContractName.Text = GetProjectUserName(ChinaSoft.Common.Input.SetInt(dr["MakeDevelopId"]));
                lblDepartContractName.Text = GetProjectUserName(ChinaSoft.Common.Input.SetInt(dr["EngineerId"]));
                lblInstituteContractName.Text = GetProjectUserName(ChinaSoft.Common.Input.SetInt(dr["SubDeanId"]));
                lblProjectName.Text = dr["ProjectName"].ToString();
            }
        }
        private string GetProjectUserName(int UserId)
        {
            string strUserName = string.Empty;
            ChinaSoft.BLL.BLL_tb_MidSoft_Users bllUsers = new ChinaSoft.BLL.BLL_tb_MidSoft_Users();
            ChinaSoft.Model.Model_tb_MidSoft_Users modelUsers = bllUsers.GetModel(UserId);
            if (modelUsers != null)
            {
                strUserName = modelUsers.UserName;
            }
            return strUserName;
        }
    }
}